const a = async function (
  _,
  _01,
  _02,
  { dc: { http, reload, message }, XLSX }
) {
  const data = await analyzExcel(XLSX);
  if (data.length && data.length > 5) {
    const list = data.slice(4);
    const keys = {
      a: "deptName",
      b: "programName1",
      c: "programName2",
      d: "ys2023",
      e: "js2023",
      f: "ys2024",
      g: "zx2024",
      h: "zxl2024",
      i: "remark",
    };
    const imp2List = [];
    list.forEach((row) => {
      const addRow = {};
      Object.keys(keys).forEach((key) => {
        addRow[keys[key]] = row[key];
        if (key === "a" && !row[key]) {
          addRow[keys[key]] = imp2List[imp2List.length - 1][keys.a];
        } else if (key === "b" && !row[key]) {
          addRow[keys[key]] = imp2List[imp2List.length - 1][keys.b];
        } else if (key === "c" && !row[key]) {
          addRow[keys[key]] = row.b;
        }
      });
      imp2List.push(addRow);
    });
    imp2List.forEach((i, index) => {
      i.sortNo = index + 1;
      if (index === imp2List.length - 1 && i.deptName === "合计") {
        i.programName1 = "合计";
        i.programName2 = "合计";
      }
    });
    await http.post({
      url: "/ypxy/reportImport/reportImport2",
      data: {
        imp2List,
      },
    });
    message.success("导入成功");
    reload();
  }
};
